package com.doctcloud.hisinfo.outpbill.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.doctcloud.common.core.utils.StringUtils;
import com.doctcloud.hisinfo.histable.domain.outpbill.OutpRcptMasterDo;
import com.doctcloud.hisinfo.outpbill.mapper.OutpRcptMasterMapper;
import com.doctcloud.hisinfo.outpbill.request.RcptMasterParm;
import com.doctcloud.hisinfo.outpbill.service.IOutpRcptMasterService;
import org.springframework.stereotype.Service;
import org.springframework.validation.annotation.Validated;

import java.util.List;

@Service
public class OutpRcptMasterService extends ServiceImpl<OutpRcptMasterMapper, OutpRcptMasterDo> implements IOutpRcptMasterService {
    @Override
    public List<OutpRcptMasterDo> listByRank(@Validated RcptMasterParm param) {
        LambdaQueryWrapper<OutpRcptMasterDo> query = Wrappers.lambdaQuery();
        if (StringUtils.isNotEmpty(param.getChargeType())){
            query.eq(OutpRcptMasterDo::getChargeType,param.getChargeType());
        }
        if (StringUtils.isNotEmpty(param.getPatientId())){
            query.eq(OutpRcptMasterDo::getPatientId,param.getPatientId());
        }
        if (StringUtils.isNotEmpty(param.getPatientName())){
            query.like(OutpRcptMasterDo::getName,param.getPatientName());
        }
        query.ge(OutpRcptMasterDo::getVisitDate,param.getStartDate())
                .le(OutpRcptMasterDo::getVisitDate,param.getEndDate());
        return baseMapper.selectList(query);
    }
}
